home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Applications / TimGA 1.2.1 / PP Archive ƒ / AGA Slider ƒ / Read Me
Encoding:
Text File  |  1997-07-16  |  13.1 KB  |  310 lines  |  [TEXT/CWIE]

  1. AGA Slider:    A demo of class CAGASlider v 1.4.4                    April 8, 1997
  2.     68K (Code works on PPC.)
  3.     CodeWarrior 11 (can work in 9 and 10)
  4.     PowerPlant
  5.  
  6. ================================================================================
  7.  
  8. AGA Slider is a project for demonstrating the CAGASlider class.
  9. It also includes CAGAProgressBar, CGAGroupBox and CBevelAttachment.
  10.  
  11. CAGASlider is a PowerPlant LControl that looks like a slider from
  12. the Apple Grayscale Appearance for System 7. It is not a CDEF.
  13.  
  14. Apple's docs on the AGA show you what things look like to the pixel,
  15. but, alas, they don't explain behaviors. I had to guess, mostly by 
  16. imitating the sliders in the system control panels. I have also added
  17. a reasonable black and white appearance.
  18.  
  19. Feel free to send me any comments, suggestions, and bug-reports to:
  20.   jennings@halcyon.com (James Jennings)
  21. Thanks to all those who have already written. The feedback was very helpful.
  22.  
  23. The AGA classes in this project are 
  24.     copyright © 1996-1997 by James Jennings. All rights reserved.
  25. This version of these classes may be freely used for non-commercial, shareware, 
  26. and commercial projects.
  27.  
  28. ================================================================================
  29.  
  30. Features of CAGASlider:
  31.  
  32.     Mouse down in the indicator shows a "pressed" indicator.
  33.     As indicator is dragged, the pressed indicator doesn't move and a "ghost" 
  34.         indicator follows the mouse.
  35.     The ghost indicator slides under the pressed indicator.
  36.     Clicking on the "track" jumps the indicator to that position.
  37.     When the mouse is released, the real indicator moves to the ghost's last position.
  38.     When the mouse is dragged away from the track, the ghost disappears. (Aborting.)
  39.     Horizontal and vertical sliders are centered in the pane. (Needs >=16 pixel width.)
  40.     "Pointing" sliders (which have tick marks) are aligned to the side of the pane away 
  41.         from the pointer and the tick marks. (Needs >=25 pixel width.)
  42.     Sliders are drawn correctly when Disabled().
  43.     Uses StOffscreenGWorld for flicker-free tracking.
  44.     Looks reasonable on black and white screens.
  45.     Looks reasonable when split across two monitors of different pixel depths. (Although,
  46.         since I only have one monitor myself, this hasn't been tested as much as I'd like.)
  47.     Has a "continuous broadcast" option for "active" sliders.
  48.     The direction of increasing values can be changed in Constructor.
  49.     The background color can be set in Constructor.
  50.  
  51. Features of CAGASliderForTabPanel:
  52.     
  53.     Changes it's background color to match that of an enabled or disabled LGATabPanel.
  54.  
  55. Features of CBevelAttachment:
  56.  
  57.     CBevelAttachment which allows you to add Grayscale Appearance
  58.         style bevels to any pane using Constructor 2.2 or later.
  59.     
  60. Limitations:
  61.     Doesn't have value labels. If you add your own (with an LCaption, say)
  62.     be sure to gray them out when the CAGASlider is disabled.
  63.     
  64.     When disabled and on a black and white screen, CGAGroupBox will draw the text 
  65.     using a gray pattern. This will render the text illegible unless you use a font 
  66.     like Chicago 12 (which the AGA standard recommends.)
  67.     
  68.     Although you can use CBevelAttachment to add a "bevel" to an LEditField, 
  69.     (as I've done in this demo), note that it doesn't change when the field is disabled. 
  70.     CBevelAttachment requires CodeWarrior 9 or later.
  71.  
  72. Version History:
  73.  
  74.     v1.4.4:
  75.         Fixed a bug (introduced in 1.4.2) that failed to always redraw the 
  76.             indicator/thumb when a drag was aborted.
  77.         Added CAGASliderForTabPanel. If LView had a way of finding the
  78.             background color of a superview, I wouldn't need this.
  79.  
  80.     v1.4.3
  81.         Added the background color to the Constructor definition. (CPPb and CTYP)
  82.             (My attempt to "auto-detect" the color didn't work with floating windows.)
  83.     
  84.     v1.4.2
  85.         SetValue() will Draw() and Enable()/Disable() will Refresh() the slider. It 
  86.             was pointed out to me that this is the way most PowerPlant LControls work.
  87.         CGAGroupBox and CAGAProgressBar now also draw themselves as appropriate.
  88.         CAGAProgressBar was reworked slightly. See CProgressDemoWindow.
  89.     
  90.     v1.4.1
  91.         Added some "#pragma unused" and "#include" directives.
  92.         The Constructor files now include the CTYP resources needed in CW11.
  93.         CAGASlider now detects and uses the background color that was drawn by the 
  94.             enclosing pane. (This didn't work in all cases and was removed in 1.4.3.)
  95.     
  96.     v1.4
  97.         CAGAProgressBar.
  98.         Fixed the slider's disabled track fill color.
  99.         
  100.     v1.3.1:
  101.         Optimized so that it tracks the mouse better on slower machines.
  102.     
  103.     v1.3:
  104.         "Ghost" indicator now slides under the real indicator. (Like the Speech control
  105.             panel does.) (Thanks to Sarwat Khan for pointing out the obvious.)
  106.         
  107.     v1.2: 
  108.         The disabled state now matches the specification on the 
  109.             September 1996 Developer CD.
  110.         The black and white disabled state is now drawn with a gray pattern.
  111.         This distribution also includes a Group Box class (CGAGroupBox) based on 
  112.         LGroupBox, and CBevelAttachment which allows you to add Grayscale Appearance
  113.             style bevels to any pane using Constructor 2.2 or later.
  114.  
  115.     v1.1: 
  116.         The direction of increasing values can be changed in Constructor.
  117.  
  118. ================================================================================
  119.  
  120. CAGASlider's CTYP/CPPb resource (for Constructor) should define these members:
  121.  
  122.     Direction:    (Int32, viewed as Text)
  123.         Values: hori, vert, nort, sout, east, west, prop
  124.         Chooses the indicator type. 
  125.         nort, sout, east, west refer to the compass direction of "pointy" indicators.
  126.         'prop' chooses hori or vert depending on the pane proportions.
  127.         Note: These values are not stored. They are converted into an enumerated 
  128.             type in the CAGASlider constructor.
  129.     Number of Tick Marks: (Uint16)
  130.         Values:
  131.             0: Don't show tick marks.
  132.             1: Show one tick mark for each allowed value of LControl::mValue.
  133.             n > 1: Show n tick marks (n-1 intervals).
  134.         Note: Number of Tick Marks is ignored for hori and vert types.
  135.     Continuous Broadcast: (Boolean)
  136.         Values:
  137.             false: BroadcastMessage() is called only when the slider is released (on mouseUp).
  138.             true:  BroadcastMessage() is called every time the value changes during a drag.
  139.     mMinValue is at Bottom or Right: (Boolean)
  140.         Values:
  141.             false: mValue == mMinValue when the slider is at the top 
  142.                 (for vertical sliders) or the left (for horizontal sliders). 
  143.                 This is the way standard scrollbars behave.
  144.             true: mValue == mMinValue when the slider is at the bottom 
  145.                 (for vertical sliders) or the right (for horizontal sliders). 
  146.                 This may be more intuitive for some vertical sliders. ("up is more")
  147.     Background Color: (RGBColor)
  148.         Values: any RGBColor. Default is AGA 2 = {0xDDDD, 0xDDDD, 0xDDDD}
  149.             A slider inside a tab group will need AGA 1 = {0xEEEE, 0xEEEE, 0xEEEE}
  150.  
  151. There is also a file called CAGASlider1.4.4.CTYP which defines CAGASlider for Constructor.
  152. It has been hacked so that the Direction appears as a pop-up menu. 
  153. The best way to use it is to place it in the same folder with Constructor 
  154. so that Constructor (v2.2 or later) will load it on startup.
  155.  
  156. *** Note: Constructor 2.2 cannot edit CAGASlider4.4.CTYP without crashing. ***
  157.           Constructor 2.3 (CW10) will politely decline to edit it.
  158.           Constructor 2.4 actually shows you the definition. Progress?
  159.  
  160. If you need a CPPb that you can edit, use the file "CAGASlider1.4.CTYP (no popup)"
  161. found in the "(Backward compatibility)" folder.
  162.  
  163. ================================================================================
  164.  
  165. CAGASliderForTabPanel is subclassed from CAGASlider and doesn't define any new members.
  166.  
  167. ================================================================================
  168.  
  169. CAGAProgressBar's CPPb/CTYP resource (for Constructor) doesn't define any new members.
  170.  
  171. "Indeterminant" Progress Bars:
  172.     Set the Minimum == the Maximum in Constructor.
  173.         (Or call SetMinValue() and SetMaxValue() with the same argument.)
  174.     Indeterminant bars are updated every time SetValue() is called, 
  175.         although the argument of SetValue() is ignored
  176.     You can keep from drawing too often by calling SetValueDelayedDrawing()
  177.  
  178. There is a file called CAGAProgressBar.CTYP which defines CAGAProgressBar for Constructor.
  179.  
  180. ================================================================================
  181.  
  182. CGAGroupBox's CPPb/CTYP resource (for Constructor) should define one member:
  183.     
  184.     Primary/Secondary: (Boolean)
  185.         Values:
  186.             true: Draw a "primary" group box.
  187.             false: Draw a "secondary" group box. (For use inside a primary group box.)
  188.  
  189. There is a file called CGAGroupBox.CTYP which defines CGAGroupBox for Constructor.
  190.  
  191. ================================================================================
  192.  
  193. CBevelAttachment's CPPb/CTYP resource (for Constructor) should define these members:
  194.  
  195.     Bevel In: (Boolean)
  196.         If true, draw a bevel that makes the pane look recessed. Otherwise,
  197.         draw a bevel that makes the pane look raised.
  198.     Width: (Int16)
  199.         How wide to draw the bevel. Usually 1 or 2.
  200.         If you make this negative, the bevel will be drawn outside the the edge 
  201.             of the pane. Note that this might not always get updated properly.
  202.     Fill with white: (Boolean)
  203.         If true, erase the center of the view with white. If false, do nothing.
  204.  
  205. There is a file called CBevelAttachment.CTYP which defines CBevelAttachment for Constructor.
  206. Note that Attachments are not supported by Constructor before version 2.2 (CW9).
  207.  
  208. ================================================================================
  209.  
  210. To add CAGASliders to your project:
  211.  
  212.     To a PowerPlant "Starter" project you will need to add the files:
  213.         CAGASlider.cp
  214.         AGA Slider Parts PICTs.rsrc
  215.         UGrayscaleAppearance.cp
  216.         UGWorld.cp
  217.     You will also need:    (in your project folder)
  218.         CAGASlider.h    
  219.         UGrayscaleAppearance.h
  220.     and:    (in Constructor's folder)
  221.         CAGASlider1.4.CTYP
  222.     You will also need to register the ClassCreatorFunc in your app's constructor.
  223.  
  224. To add CAGAProgressBar to your project:
  225.  
  226.     To a PowerPlant "Starter" project you will need to add the files:
  227.         CAGAProgressBar.cp
  228.         AGA Progress Bar Parts.rsrc
  229.         UGrayscaleAppearance.cp
  230.         UGWorld.cp
  231.     You will also need:    (in your project folder)
  232.         CAGAProgressBar.h    
  233.         UGrayscaleAppearance.h
  234.     and:    (in Constructor's folder)
  235.         CAGAProgressBar.CTYP
  236.     You will also need to register the ClassCreatorFunc in your app's constructor.
  237.  
  238. To add CGAGroupBox to your project:
  239.  
  240.     To a PowerPlant "Starter"  project you will need to add the files:
  241.         LGroupBox.cp
  242.         CGAGroupBox.cp
  243.         UGrayscaleAppearance.cp
  244.     You will also need:
  245.         LGroupBox.h
  246.         CGAGroupBox.h
  247.         UGrayscaleAppearance.h
  248.         CGAGroupBox.CTYP (in Constructor's folder)
  249.     You will also need to register the ClassCreatorFunc in your app's constructor.
  250.  
  251. To add CBevelAttachment to your project:
  252.  
  253.     To a PowerPlant "Starter"  project you will need to add the files:
  254.         CBevelAttachment.cp
  255.         UGrayscaleAppearance.cp
  256.     You will also need:
  257.         CodeWarrior release 9 or later.
  258.         CBevelAttachment.h
  259.         UGrayscaleAppearance.h
  260.         CBevelAttachment.CTYP (in Constructor's folder)
  261.     You will also need to register the ClassCreatorFunc in your app's constructor.
  262.  
  263. ================================================================================
  264.  
  265. Programming Notes:
  266.  
  267. CAGASlider inherits from LControl and UGrayscaleAppearance.
  268. CAGAProgressBar inherits from LControl and UGrayscaleAppearance.
  269. CGAGroupBox inherits from LGroupBox and UGrayscaleAppearance.
  270. CBevelAttachment inherits from LAttachment and UGrayscaleAppearance.
  271.  
  272. UGrayscaleAppearance encapsulates the AGA color definitions and a few utility functions.
  273.  
  274. I set the background color of the Demo's windows to gray by setting its "content" color 
  275. in ResEdit. This adds a 'wctb' resource. There is no code in the project that draws 
  276. the background color for the whole window, just for the sliders.
  277.  
  278. The slider allocates some memory for holding the indicator (thumb) images. These
  279. images are shared by all sliders in the application, and normally hang around 
  280. until the application quits. If you want to be really fanatic about freeing up 
  281. memory (it's only a few K), you can call CAGASlider::Purge().
  282.  
  283. The progress bar allocates some memory for holding fill patterns and such. These 
  284. graphics are shared by all progress bars in the application, and normally hang around 
  285. until the application quits. If you want to be really fanatic about freeing up 
  286. memory (it's only a few K), you can call CAGAProgressBar::Purge().
  287.  
  288. I deliberately made the slider so that the indicator "snapped to" the allowed
  289. values of the slider. If you want a smoother feel, try increasing the range
  290. of the slider values until it looks smooth, and then adjust the result of GetValue()
  291. before you use it. For an example, note that the demo has some sliders with 10 
  292. intervals, and some with 100 intervals.
  293.  
  294. When I switched from Apple's April 96 specification to the Sept 96 specification, I 
  295. made it conditionally compiled. To revert to the April specification:
  296.     #define AGA_VERSION 1 in both CAGASlider and CGAGroupBox
  297.     Replace the file "AGA Slider Parts PICTs.rsrc" with "AGA Slider Parts PICTs Apr.rsrc"
  298.  
  299. Progress Bars are drawn 14 pixels high. In Constructor, set the pane height to 
  300. at least 14. More doesn't hurt. Less will trigger some debugging code.
  301.     
  302. CBevelAttachment requires Codewarrior release 9 or better.
  303. To compile the demo under CW8 or earlier:
  304.     1) replace the file "AGA Slider.rsrc" with "AGA Slider.rsrc (no bevel)"
  305.     2) remove the file CBevelAttachment.cp from the project.
  306.     3) remove the references to CBevelAttachment that appear in AGASliderApp.cp
  307.  
  308. James Jennings
  309. jennings@halcyon.com
  310.